package com.pc.store.controller;
import com.pc.store.entity.Order;
import com.pc.store.service.IOrderService;
import com.pc.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;

@RequestMapping("orders")
@RestController

public class OrderController extends BaseController {
    @Autowired
    private IOrderService orderService;

    @RequestMapping("create")
    public JsonResult<Order> create(Integer aid, Integer[] cids, HttpSession session) {
        Integer uid=getuidFromSession(session);
        String username=getUsernameFromSession(session);
        Order data = orderService.create(
                aid,
                cids,
                uid,
                username);
        return new JsonResult<>(OK,data);
    }
}
